package cn.ibizlab.odoo.core.odoo_account.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Iaccount_invoice;
import cn.ibizlab.odoo.core.odoo_account.domain.Account_invoice;
import cn.ibizlab.odoo.core.odoo_account.filter.Account_invoiceSearchContext;
import cn.ibizlab.odoo.core.odoo_account.service.IAccount_invoiceService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[发票] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Account_invoiceServiceImpl implements IAccount_invoiceService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Iaccount_invoiceClientService account_invoiceClientService;

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Iaccount_invoice clientModel = account_invoiceClientService.createModel();
        clientModel.setId(id);
        account_invoiceClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public boolean create(Account_invoice account_invoice) {
        boolean bOk = false ;
        Iaccount_invoice clientModel = this.convert2Model(account_invoice,null);
        account_invoiceClientService.create(clientModel) ;
        this.convert2Domain(clientModel,account_invoice);
        bOk = true ;

        return bOk ;
    }

    @Override
    public boolean update(Account_invoice account_invoice) {
        boolean bOk = false ;
        Iaccount_invoice clientModel = this.convert2Model(account_invoice,null);
        account_invoiceClientService.update(clientModel) ;
        this.convert2Domain(clientModel,account_invoice) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public void updateBatch(List<Account_invoice> account_invoices, int batchSize) {

        //account_invoiceClientService.updateBatch(account_invoices,batchSize) ;

    }

    @Override
    public Account_invoice get(Integer id) {
        Iaccount_invoice clientModel = account_invoiceClientService.createModel();
        clientModel.setId(id);
        account_invoiceClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Account_invoice get(Account_invoice account_invoice) {
        Account_invoice retaccount_invoice = this.get(account_invoice.getId()) ;
    	BeanCopier copier=BeanCopier.create(retaccount_invoice.getClass(), account_invoice.getClass(), false);
        copier.copy(retaccount_invoice, account_invoice, null);
        return account_invoice ;
    }

    @Override
    public void createBatch(List<Account_invoice> account_invoices, int batchSize) {

                        //account_invoiceClientService.createBatch(account_invoices,batchSize) ;

    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //account_invoiceClientService.removeBatch(account_invoices) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Account_invoice> searchDefault(Account_invoiceSearchContext context) {
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据科目查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_account(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据帐户现金舍入查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_cash_rounding(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据税科目调整查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_fiscal_position(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据贸易条款查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_incoterms(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据贸易条款查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_incoterm(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据发票查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_refund_invoice(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据发票查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_vendor_bill(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据日记账查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_journal(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据凭证录入查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_move(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据付款条款查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_payment_term(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据销售渠道查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_team(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据采购 & 账单查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_vendor_bill_purchase(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据采购订单查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_purchase(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_company(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据币种查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_currency(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据银行账户查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_partner_bank(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_commercial_partner(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_partner(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_partner_shipping(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_create(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_user(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_write(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据UTM 营销活动查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_campaign(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据UTM媒体查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_medium(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据UTM来源查询
     */
    @Override
    public Page<Account_invoice> selectByOdoo_source(Integer id){
        Account_invoiceSearchContext context = new Account_invoiceSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Account_invoice> list = new ArrayList<Account_invoice>();
        Page<cn.ibizlab.odoo.core.client.model.Iaccount_invoice> clientModelList = account_invoiceClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Iaccount_invoice clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Account_invoice>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Iaccount_invoice convert2Model(Account_invoice domain , Iaccount_invoice model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = account_invoiceClientService.createModel() ;
        }

         if(domain.getOutstanding_credits_debits_widgetDirtyFlag())
            model.setOutstanding_credits_debits_widget(domain.getOutstanding_credits_debits_widget());
         if(domain.getActivity_date_deadlineDirtyFlag())
            model.setActivity_date_deadline(domain.getActivity_date_deadline());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getMove_nameDirtyFlag())
            model.setMove_name(domain.getMove_name());
         if(domain.getActivity_summaryDirtyFlag())
            model.setActivity_summary(domain.getActivity_summary());
         if(domain.getAccess_urlDirtyFlag())
            model.setAccess_url(domain.getAccess_url());
         if(domain.getPayment_move_line_idsDirtyFlag())
            model.setPayment_move_line_ids(domain.getPayment_move_line_ids());
         if(domain.getOriginDirtyFlag())
            model.setOrigin(domain.getOrigin());
         if(domain.getDateDirtyFlag())
            model.setDate(domain.getDate());
         if(domain.getAmount_total_company_signedDirtyFlag())
            model.setAmount_total_company_signed(domain.getAmount_total_company_signed());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getAmount_untaxed_signedDirtyFlag())
            model.setAmount_untaxed_signed(domain.getAmount_untaxed_signed());
         if(domain.getResidualDirtyFlag())
            model.setResidual(domain.getResidual());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getHas_outstandingDirtyFlag())
            model.setHas_outstanding(domain.getHas_outstanding());
         if(domain.getCommentDirtyFlag())
            model.setComment(domain.getComment());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getActivity_type_idDirtyFlag())
            model.setActivity_type_id(domain.getActivity_type_id());
         if(domain.getAmount_by_groupDirtyFlag())
            model.setAmount_by_group(domain.getAmount_by_group());
         if(domain.getPayments_widgetDirtyFlag())
            model.setPayments_widget(domain.getPayments_widget());
         if(domain.getReconciledDirtyFlag())
            model.setReconciled(domain.getReconciled());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getSentDirtyFlag())
            model.setSent(domain.getSent());
         if(domain.getAmount_total_signedDirtyFlag())
            model.setAmount_total_signed(domain.getAmount_total_signed());
         if(domain.getInvoice_line_idsDirtyFlag())
            model.setInvoice_line_ids(domain.getInvoice_line_ids());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getAccess_warningDirtyFlag())
            model.setAccess_warning(domain.getAccess_warning());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getActivity_stateDirtyFlag())
            model.setActivity_state(domain.getActivity_state());
         if(domain.getResidual_signedDirtyFlag())
            model.setResidual_signed(domain.getResidual_signed());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getAccess_tokenDirtyFlag())
            model.setAccess_token(domain.getAccess_token());
         if(domain.getVendor_display_nameDirtyFlag())
            model.setVendor_display_name(domain.getVendor_display_name());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getAmount_untaxedDirtyFlag())
            model.setAmount_untaxed(domain.getAmount_untaxed());
         if(domain.getTransaction_idsDirtyFlag())
            model.setTransaction_ids(domain.getTransaction_ids());
         if(domain.getDate_dueDirtyFlag())
            model.setDate_due(domain.getDate_due());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getAuthorized_transaction_idsDirtyFlag())
            model.setAuthorized_transaction_ids(domain.getAuthorized_transaction_ids());
         if(domain.getTax_line_idsDirtyFlag())
            model.setTax_line_ids(domain.getTax_line_ids());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getSource_emailDirtyFlag())
            model.setSource_email(domain.getSource_email());
         if(domain.getAmount_taxDirtyFlag())
            model.setAmount_tax(domain.getAmount_tax());
         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getAmount_untaxed_invoice_signedDirtyFlag())
            model.setAmount_untaxed_invoice_signed(domain.getAmount_untaxed_invoice_signed());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getSequence_number_next_prefixDirtyFlag())
            model.setSequence_number_next_prefix(domain.getSequence_number_next_prefix());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getRefund_invoice_idsDirtyFlag())
            model.setRefund_invoice_ids(domain.getRefund_invoice_ids());
         if(domain.getResidual_company_signedDirtyFlag())
            model.setResidual_company_signed(domain.getResidual_company_signed());
         if(domain.getDate_invoiceDirtyFlag())
            model.setDate_invoice(domain.getDate_invoice());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getActivity_user_idDirtyFlag())
            model.setActivity_user_id(domain.getActivity_user_id());
         if(domain.getReferenceDirtyFlag())
            model.setReference(domain.getReference());
         if(domain.getWebsite_idDirtyFlag())
            model.setWebsite_id(domain.getWebsite_id());
         if(domain.getSequence_number_nextDirtyFlag())
            model.setSequence_number_next(domain.getSequence_number_next());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getAmount_tax_signedDirtyFlag())
            model.setAmount_tax_signed(domain.getAmount_tax_signed());
         if(domain.getInvoice_iconDirtyFlag())
            model.setInvoice_icon(domain.getInvoice_icon());
         if(domain.getPayment_idsDirtyFlag())
            model.setPayment_ids(domain.getPayment_ids());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getAmount_totalDirtyFlag())
            model.setAmount_total(domain.getAmount_total());
         if(domain.getActivity_idsDirtyFlag())
            model.setActivity_ids(domain.getActivity_ids());
         if(domain.getTypeDirtyFlag())
            model.setType(domain.getType());
         if(domain.getJournal_id_textDirtyFlag())
            model.setJournal_id_text(domain.getJournal_id_text());
         if(domain.getPurchase_id_textDirtyFlag())
            model.setPurchase_id_text(domain.getPurchase_id_text());
         if(domain.getVendor_bill_purchase_id_textDirtyFlag())
            model.setVendor_bill_purchase_id_text(domain.getVendor_bill_purchase_id_text());
         if(domain.getSource_id_textDirtyFlag())
            model.setSource_id_text(domain.getSource_id_text());
         if(domain.getCampaign_id_textDirtyFlag())
            model.setCampaign_id_text(domain.getCampaign_id_text());
         if(domain.getPartner_shipping_id_textDirtyFlag())
            model.setPartner_shipping_id_text(domain.getPartner_shipping_id_text());
         if(domain.getCurrency_id_textDirtyFlag())
            model.setCurrency_id_text(domain.getCurrency_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getIncoterms_id_textDirtyFlag())
            model.setIncoterms_id_text(domain.getIncoterms_id_text());
         if(domain.getCompany_currency_idDirtyFlag())
            model.setCompany_currency_id(domain.getCompany_currency_id());
         if(domain.getAccount_id_textDirtyFlag())
            model.setAccount_id_text(domain.getAccount_id_text());
         if(domain.getIncoterm_id_textDirtyFlag())
            model.setIncoterm_id_text(domain.getIncoterm_id_text());
         if(domain.getPartner_id_textDirtyFlag())
            model.setPartner_id_text(domain.getPartner_id_text());
         if(domain.getMedium_id_textDirtyFlag())
            model.setMedium_id_text(domain.getMedium_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getCash_rounding_id_textDirtyFlag())
            model.setCash_rounding_id_text(domain.getCash_rounding_id_text());
         if(domain.getVendor_bill_id_textDirtyFlag())
            model.setVendor_bill_id_text(domain.getVendor_bill_id_text());
         if(domain.getRefund_invoice_id_textDirtyFlag())
            model.setRefund_invoice_id_text(domain.getRefund_invoice_id_text());
         if(domain.getFiscal_position_id_textDirtyFlag())
            model.setFiscal_position_id_text(domain.getFiscal_position_id_text());
         if(domain.getNumberDirtyFlag())
            model.setNumber(domain.getNumber());
         if(domain.getCommercial_partner_id_textDirtyFlag())
            model.setCommercial_partner_id_text(domain.getCommercial_partner_id_text());
         if(domain.getTeam_id_textDirtyFlag())
            model.setTeam_id_text(domain.getTeam_id_text());
         if(domain.getPayment_term_id_textDirtyFlag())
            model.setPayment_term_id_text(domain.getPayment_term_id_text());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
         if(domain.getTeam_idDirtyFlag())
            model.setTeam_id(domain.getTeam_id());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getAccount_idDirtyFlag())
            model.setAccount_id(domain.getAccount_id());
         if(domain.getMedium_idDirtyFlag())
            model.setMedium_id(domain.getMedium_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getMove_idDirtyFlag())
            model.setMove_id(domain.getMove_id());
         if(domain.getPayment_term_idDirtyFlag())
            model.setPayment_term_id(domain.getPayment_term_id());
         if(domain.getJournal_idDirtyFlag())
            model.setJournal_id(domain.getJournal_id());
         if(domain.getIncoterm_idDirtyFlag())
            model.setIncoterm_id(domain.getIncoterm_id());
         if(domain.getPurchase_idDirtyFlag())
            model.setPurchase_id(domain.getPurchase_id());
         if(domain.getFiscal_position_idDirtyFlag())
            model.setFiscal_position_id(domain.getFiscal_position_id());
         if(domain.getRefund_invoice_idDirtyFlag())
            model.setRefund_invoice_id(domain.getRefund_invoice_id());
         if(domain.getCurrency_idDirtyFlag())
            model.setCurrency_id(domain.getCurrency_id());
         if(domain.getPartner_idDirtyFlag())
            model.setPartner_id(domain.getPartner_id());
         if(domain.getPartner_bank_idDirtyFlag())
            model.setPartner_bank_id(domain.getPartner_bank_id());
         if(domain.getCash_rounding_idDirtyFlag())
            model.setCash_rounding_id(domain.getCash_rounding_id());
         if(domain.getCommercial_partner_idDirtyFlag())
            model.setCommercial_partner_id(domain.getCommercial_partner_id());
         if(domain.getPartner_shipping_idDirtyFlag())
            model.setPartner_shipping_id(domain.getPartner_shipping_id());
         if(domain.getIncoterms_idDirtyFlag())
            model.setIncoterms_id(domain.getIncoterms_id());
         if(domain.getSource_idDirtyFlag())
            model.setSource_id(domain.getSource_id());
         if(domain.getVendor_bill_idDirtyFlag())
            model.setVendor_bill_id(domain.getVendor_bill_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getVendor_bill_purchase_idDirtyFlag())
            model.setVendor_bill_purchase_id(domain.getVendor_bill_purchase_id());
         if(domain.getCampaign_idDirtyFlag())
            model.setCampaign_id(domain.getCampaign_id());
        return model ;
    }

    public Account_invoice convert2Domain( Iaccount_invoice model ,Account_invoice domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Account_invoice();
        }

        if(model.getOutstanding_credits_debits_widgetDirtyFlag())
            domain.setOutstanding_credits_debits_widget(model.getOutstanding_credits_debits_widget());
        if(model.getActivity_date_deadlineDirtyFlag())
            domain.setActivity_date_deadline(model.getActivity_date_deadline());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getMove_nameDirtyFlag())
            domain.setMove_name(model.getMove_name());
        if(model.getActivity_summaryDirtyFlag())
            domain.setActivity_summary(model.getActivity_summary());
        if(model.getAccess_urlDirtyFlag())
            domain.setAccess_url(model.getAccess_url());
        if(model.getPayment_move_line_idsDirtyFlag())
            domain.setPayment_move_line_ids(model.getPayment_move_line_ids());
        if(model.getOriginDirtyFlag())
            domain.setOrigin(model.getOrigin());
        if(model.getDateDirtyFlag())
            domain.setDate(model.getDate());
        if(model.getAmount_total_company_signedDirtyFlag())
            domain.setAmount_total_company_signed(model.getAmount_total_company_signed());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getAmount_untaxed_signedDirtyFlag())
            domain.setAmount_untaxed_signed(model.getAmount_untaxed_signed());
        if(model.getResidualDirtyFlag())
            domain.setResidual(model.getResidual());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getHas_outstandingDirtyFlag())
            domain.setHas_outstanding(model.getHas_outstanding());
        if(model.getCommentDirtyFlag())
            domain.setComment(model.getComment());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getActivity_type_idDirtyFlag())
            domain.setActivity_type_id(model.getActivity_type_id());
        if(model.getAmount_by_groupDirtyFlag())
            domain.setAmount_by_group(model.getAmount_by_group());
        if(model.getPayments_widgetDirtyFlag())
            domain.setPayments_widget(model.getPayments_widget());
        if(model.getReconciledDirtyFlag())
            domain.setReconciled(model.getReconciled());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getSentDirtyFlag())
            domain.setSent(model.getSent());
        if(model.getAmount_total_signedDirtyFlag())
            domain.setAmount_total_signed(model.getAmount_total_signed());
        if(model.getInvoice_line_idsDirtyFlag())
            domain.setInvoice_line_ids(model.getInvoice_line_ids());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getAccess_warningDirtyFlag())
            domain.setAccess_warning(model.getAccess_warning());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getActivity_stateDirtyFlag())
            domain.setActivity_state(model.getActivity_state());
        if(model.getResidual_signedDirtyFlag())
            domain.setResidual_signed(model.getResidual_signed());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getAccess_tokenDirtyFlag())
            domain.setAccess_token(model.getAccess_token());
        if(model.getVendor_display_nameDirtyFlag())
            domain.setVendor_display_name(model.getVendor_display_name());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getAmount_untaxedDirtyFlag())
            domain.setAmount_untaxed(model.getAmount_untaxed());
        if(model.getTransaction_idsDirtyFlag())
            domain.setTransaction_ids(model.getTransaction_ids());
        if(model.getDate_dueDirtyFlag())
            domain.setDate_due(model.getDate_due());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getAuthorized_transaction_idsDirtyFlag())
            domain.setAuthorized_transaction_ids(model.getAuthorized_transaction_ids());
        if(model.getTax_line_idsDirtyFlag())
            domain.setTax_line_ids(model.getTax_line_ids());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getSource_emailDirtyFlag())
            domain.setSource_email(model.getSource_email());
        if(model.getAmount_taxDirtyFlag())
            domain.setAmount_tax(model.getAmount_tax());
        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getAmount_untaxed_invoice_signedDirtyFlag())
            domain.setAmount_untaxed_invoice_signed(model.getAmount_untaxed_invoice_signed());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getSequence_number_next_prefixDirtyFlag())
            domain.setSequence_number_next_prefix(model.getSequence_number_next_prefix());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getRefund_invoice_idsDirtyFlag())
            domain.setRefund_invoice_ids(model.getRefund_invoice_ids());
        if(model.getResidual_company_signedDirtyFlag())
            domain.setResidual_company_signed(model.getResidual_company_signed());
        if(model.getDate_invoiceDirtyFlag())
            domain.setDate_invoice(model.getDate_invoice());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getActivity_user_idDirtyFlag())
            domain.setActivity_user_id(model.getActivity_user_id());
        if(model.getReferenceDirtyFlag())
            domain.setReference(model.getReference());
        if(model.getWebsite_idDirtyFlag())
            domain.setWebsite_id(model.getWebsite_id());
        if(model.getSequence_number_nextDirtyFlag())
            domain.setSequence_number_next(model.getSequence_number_next());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getAmount_tax_signedDirtyFlag())
            domain.setAmount_tax_signed(model.getAmount_tax_signed());
        if(model.getInvoice_iconDirtyFlag())
            domain.setInvoice_icon(model.getInvoice_icon());
        if(model.getPayment_idsDirtyFlag())
            domain.setPayment_ids(model.getPayment_ids());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getAmount_totalDirtyFlag())
            domain.setAmount_total(model.getAmount_total());
        if(model.getActivity_idsDirtyFlag())
            domain.setActivity_ids(model.getActivity_ids());
        if(model.getTypeDirtyFlag())
            domain.setType(model.getType());
        if(model.getJournal_id_textDirtyFlag())
            domain.setJournal_id_text(model.getJournal_id_text());
        if(model.getPurchase_id_textDirtyFlag())
            domain.setPurchase_id_text(model.getPurchase_id_text());
        if(model.getVendor_bill_purchase_id_textDirtyFlag())
            domain.setVendor_bill_purchase_id_text(model.getVendor_bill_purchase_id_text());
        if(model.getSource_id_textDirtyFlag())
            domain.setSource_id_text(model.getSource_id_text());
        if(model.getCampaign_id_textDirtyFlag())
            domain.setCampaign_id_text(model.getCampaign_id_text());
        if(model.getPartner_shipping_id_textDirtyFlag())
            domain.setPartner_shipping_id_text(model.getPartner_shipping_id_text());
        if(model.getCurrency_id_textDirtyFlag())
            domain.setCurrency_id_text(model.getCurrency_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getIncoterms_id_textDirtyFlag())
            domain.setIncoterms_id_text(model.getIncoterms_id_text());
        if(model.getCompany_currency_idDirtyFlag())
            domain.setCompany_currency_id(model.getCompany_currency_id());
        if(model.getAccount_id_textDirtyFlag())
            domain.setAccount_id_text(model.getAccount_id_text());
        if(model.getIncoterm_id_textDirtyFlag())
            domain.setIncoterm_id_text(model.getIncoterm_id_text());
        if(model.getPartner_id_textDirtyFlag())
            domain.setPartner_id_text(model.getPartner_id_text());
        if(model.getMedium_id_textDirtyFlag())
            domain.setMedium_id_text(model.getMedium_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getCash_rounding_id_textDirtyFlag())
            domain.setCash_rounding_id_text(model.getCash_rounding_id_text());
        if(model.getVendor_bill_id_textDirtyFlag())
            domain.setVendor_bill_id_text(model.getVendor_bill_id_text());
        if(model.getRefund_invoice_id_textDirtyFlag())
            domain.setRefund_invoice_id_text(model.getRefund_invoice_id_text());
        if(model.getFiscal_position_id_textDirtyFlag())
            domain.setFiscal_position_id_text(model.getFiscal_position_id_text());
        if(model.getNumberDirtyFlag())
            domain.setNumber(model.getNumber());
        if(model.getCommercial_partner_id_textDirtyFlag())
            domain.setCommercial_partner_id_text(model.getCommercial_partner_id_text());
        if(model.getTeam_id_textDirtyFlag())
            domain.setTeam_id_text(model.getTeam_id_text());
        if(model.getPayment_term_id_textDirtyFlag())
            domain.setPayment_term_id_text(model.getPayment_term_id_text());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        if(model.getTeam_idDirtyFlag())
            domain.setTeam_id(model.getTeam_id());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getAccount_idDirtyFlag())
            domain.setAccount_id(model.getAccount_id());
        if(model.getMedium_idDirtyFlag())
            domain.setMedium_id(model.getMedium_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getMove_idDirtyFlag())
            domain.setMove_id(model.getMove_id());
        if(model.getPayment_term_idDirtyFlag())
            domain.setPayment_term_id(model.getPayment_term_id());
        if(model.getJournal_idDirtyFlag())
            domain.setJournal_id(model.getJournal_id());
        if(model.getIncoterm_idDirtyFlag())
            domain.setIncoterm_id(model.getIncoterm_id());
        if(model.getPurchase_idDirtyFlag())
            domain.setPurchase_id(model.getPurchase_id());
        if(model.getFiscal_position_idDirtyFlag())
            domain.setFiscal_position_id(model.getFiscal_position_id());
        if(model.getRefund_invoice_idDirtyFlag())
            domain.setRefund_invoice_id(model.getRefund_invoice_id());
        if(model.getCurrency_idDirtyFlag())
            domain.setCurrency_id(model.getCurrency_id());
        if(model.getPartner_idDirtyFlag())
            domain.setPartner_id(model.getPartner_id());
        if(model.getPartner_bank_idDirtyFlag())
            domain.setPartner_bank_id(model.getPartner_bank_id());
        if(model.getCash_rounding_idDirtyFlag())
            domain.setCash_rounding_id(model.getCash_rounding_id());
        if(model.getCommercial_partner_idDirtyFlag())
            domain.setCommercial_partner_id(model.getCommercial_partner_id());
        if(model.getPartner_shipping_idDirtyFlag())
            domain.setPartner_shipping_id(model.getPartner_shipping_id());
        if(model.getIncoterms_idDirtyFlag())
            domain.setIncoterms_id(model.getIncoterms_id());
        if(model.getSource_idDirtyFlag())
            domain.setSource_id(model.getSource_id());
        if(model.getVendor_bill_idDirtyFlag())
            domain.setVendor_bill_id(model.getVendor_bill_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getVendor_bill_purchase_idDirtyFlag())
            domain.setVendor_bill_purchase_id(model.getVendor_bill_purchase_id());
        if(model.getCampaign_idDirtyFlag())
            domain.setCampaign_id(model.getCampaign_id());
        return domain ;
    }


}
